﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace LibrarySystem
{
    public partial class ModifyData : Form
    {
        string User;
        SqlConnection Connection_Main = new SqlConnection();
        //string str;
        AppManager LIB2 = new AppManager();
        public ModifyData(string Name)
        {
            InitializeComponent();
            User = Name;
        }

        private void ModifyData_Load(object sender, EventArgs e)
        {
            labelmessege.Text = "";
            label6.Text = User;
            label10.Text = User;
            LIB2.ComboDisplayChoose3(comboBox1, "select * from alssafa.dbo.EMPLOYEE where الإسم = '" + label6.Text + "'", "EMPLOYEE", "الرقم_القومي", label13);
            LIB2.ComboDisplayChoose3(comboBox2, "select * from alssafa.dbo.EMPLOYEE where الإسم = '" + label6.Text + "'", "EMPLOYEE", "الوظيفة", label11);
            LIB2.ComboDisplayChoose3(comboBox3, "select * from alssafa.dbo.EMPLOYEE where الإسم = '" + label6.Text + "'", "EMPLOYEE", "الراتب_الشهري", label14);
            LIB2.ComboDisplayChoose3(comboBox4, "select * from alssafa.dbo.EMPLOYEE where الإسم = '" + label6.Text + "'", "EMPLOYEE", "تاريخ_الميلاد", label12);
            LIB2.ComboDisplayChoose(comboBox5, "select * from alssafa.dbo.EMPLOYEE where الإسم = '" + label6.Text + "'", "EMPLOYEE", "الهاتف", textBox1);
            LIB2.ComboDisplayChoose(comboBox6, "select * from alssafa.dbo.EMPLOYEE where الإسم = '" + label6.Text + "'", "EMPLOYEE", "العنوان", textBox2);
            LIB2.ComboDisplayChoose(comboBox7, "select * from alssafa.dbo.EMPLOYEE where الإسم = '" + label6.Text + "'", "EMPLOYEE", "البريد_الاكتروني", textBox3);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length <= 11 && textBox1.Text.Length >= 8)
            {
                if (textBox2.Text.Length > 0)
                {

                    if ((MessageBox.Show("هل تريد إجراء هذه التعديلات؟", "تأكيد التعديل", MessageBoxButtons.YesNo)) == System.Windows.Forms.DialogResult.Yes)
                    {

                        LIB2.update("UPDATE EMPLOYEE SET الهاتف=" + textBox1.Text + " where الإسم='" + label6.Text + "'");
                        LIB2.update("UPDATE EMPLOYEE SET العنوان='" + textBox2.Text + "' where الإسم='" + label6.Text + "'");
                        LIB2.update("UPDATE EMPLOYEE SET البريد_الاكتروني='" + textBox3.Text + "' where الإسم='" + label6.Text + "'");
                        labelmessege.Text = "";
                        this.Close();
                    }
                }
                else
                    labelmessege.Text = "أدخل العنوان الصحيح";
            }
            else
                labelmessege.Text = "رقم الهاتف غير صحيح";
        }
    }
}
